<!DOCTYPE html>
<html lang="en">
<head>
    <head>
        <meta charset="utf-8">
        <title>演员管理</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="../../lib/layui/css/layui.css" media="all">
        <link rel="stylesheet" href="../../lib/layui/css/layui.mobile.css" media="all">
        <link rel="stylesheet" href="../../css/public.css" media="all">
        <style>
            body {
                background-color: #ffffff;
            }
        </style>
    </head>
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px">
            <legend>添加演员</legend>
        </fieldset>

        <form class="layui-form" action="">
            <div class="layui-form-item layui-col-md10">
                <label class="layui-form-label">演员名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="name" autocomplete="off" placeholder="请输入演员姓名"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-inline layui-col-md4">
                    <label class="layui-form-label">联系方式</label>
                    <div class="layui-input-block">
                        <input type="text" lay-verify="telephone" name="telephone" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
                <div class="layui-inline layui-col-md5">
                    <label class="layui-form-label">出生日期</label>
                    <div class="layui-input-block">
                        <input type="text" name="birthday" id="birthday" lay-verify="birthday" class="layui-input"
                               autocomplete="off" placeholder="yyyy-MM-dd HH:mm:ss">
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" name="gender" value="Male" title="男演员">
                    <input type="radio" name="gender" value="Female" title="女演员">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">演员简介</label>
                <div class="layui-input-block">
                    <textarea class="layui-textarea" id="lay_intro_editor" lay-verfiy="intro" name="intro"></textarea>
                </div>
            </div>

            <!--表单提交控制Item-->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" type="button" lay-submit="" lay-filter="save">立即提交</button>
                    <button class="layui-btn layui-btn-primary" type="reset">重置表单</button>
                </div>
            </div>

        </form>
    </div>
</div>

<script src="../../lib/layui/layui.all.js" charset="utf-8"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'laydate'], function () {
        // let {form, layer, layedit, laydate} = [layui.form, layui.layer, layui.layedit, layui.laydate];
        var form = layui.form,
            layer = layui.layer,
            layedit = layui.layedit,
            laydate = layui.laydate;

        laydate.render({
            elem: '#birthday',
            type: 'datetime',
            format: 'yyyy年MM月dd日 HH时mm分ss秒',
        });

        var introEditorIndex = layedit.build('lay_intro_editor');

        // 自定表单校验脚本
        form.verify({
            name: function (value) {
                if (value.length < 1) {
                    return '姓名不能为空';
                }
            },
            intro: function (value) {
                layedit.sync(introEditorIndex);

            }
        });

        // 监听表单提交事件
        form.on('submit(save)', function (data) {
            console.log('save data', data);
            layer.alert(JSON.stringify(data.field), {
                title: '表单信息',
            });
            return false;
        });

    });
</script>

</body>
</html>
